#include "Robot.h"


Robot::Robot(Room &_oRoom, const string &_sName)
: m_pRoom(&_oRoom)
, m_sName(_sName)
{

}

Robot::~Robot()
{
	for(unsigned int i = 0; i < m_vMaterialList.size(); i++)
	{
		delete(m_vMaterialList[i]);
	}
}

bool Robot::takeExit(const unsigned int _uiExitIndex)
{
	const Exit *exit = this->getRoom().getExit(_uiExitIndex);
	if(exit == 0)
	{
		return false;
	}

	this->setRoom(exit->getEndRoom());
	return true;
}


void Robot::takeMaterials()
{
	this->m_vMaterialList.add(this->getRoom().getMaterialList());
	this->m_pRoom->clearMaterials();
}

const char *Robot::reportMaterialList() const
{
	return Material::reportMaterialList(this->m_vMaterialList);
}

void Robot::putDownMaterials()
{
	this->m_pRoom->addMaterial(this->m_vMaterialList);
	this->m_vMaterialList.clear();
}

const Room &Robot::getRoom() const
{
	return *this->m_pRoom;
}

const char *Robot::getName() const
{
	return this->m_sName.c_str();
}

void Robot::setRoom(const Room &_oRoom)
{
	this->m_pRoom = const_cast<Room *>(&_oRoom);
}